{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Two ways to connect to milvus from a notebook\n",
    "\n",
    "There are 5 different ways to start up a Milvus server.\n",
    "1. 🥳 Milvus Local Python server is coming soon!  \n",
    "   ⛔️ Only meant for demos and local testing.\n",
    "\n",
    "💡 **For production purposes**, it is recommended to use Milvus local docker, clusters, or fully-managed Milvus on Zilliz Cloud. <br>\n",
    "\n",
    "2. [Milvus standalone docker](https://milvus.io/docs/install_standalone-docker.md) requires local docker installed and running.\n",
    "3. [Ziliz Cloud free tier](#zilliz_free)\n",
    "4. <a href=\"https://milvus.io/docs/install_cluster-milvusoperator.md\">Milvus clusters</a> requires a K8s cluster up and running.\n",
    "5. <a href=\"https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.milvus.Milvus.html\">LangChain Milvus</a> and other 3rd party adapters.\n",
    "\n",
    "Once your milvus server or cluster is up and running, you're all set to make API calls.  I'll demonstrate how to do this using the [Python SDK](https://github.com/milvus-io/pymilvus/blob/master/pymilvus/milvus_client/milvus_client.py).  You can also check out a [practical example](https://github.com/milvus-io/pymilvus/blob/bac31951d5c5a9dacb6632e535e3c4d284726390/examples/hello_milvus_simple.py).  "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Notebook contents for 2 ways to connect\n",
    "1. [Local milvus on docker demo](#milvus_docker)\n",
    "2. [Zilliz cloud free tier](#zilliz_free)\n",
    "3. Milvus clusters on K8 - demo coming soon\n",
    "4. 3rd party adapters - demo coming soon"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1. Milvus standalone server running on Docker <a class=\"anchor\" id=\"milvus_docker\"></a>\n",
    "\n",
    "This section uses [Milvus standalone](https://milvus.io/docs/configure-docker.md) on Docker on your laptop. <br>\n",
    ">⛔️ Make sure you pip install the correct version of pymilvus and server yml file.  **Versions (major and minor) should all match**.\n",
    "\n",
    "1. [Install Docker](https://docs.docker.com/get-docker/)\n",
    "2. Start your Docker Desktop\n",
    "3. Download the latest [docker-compose.yml](https://milvus.io/docs/install_standalone-docker.md#Download-the-YAML-file) (or run the wget command, replacing version to what you are using)\n",
    "> wget https://github.com/milvus-io/milvus/releases/download/v2.4.0-rc.1/milvus-standalone-docker-compose.yml -O docker-compose.yml\n",
    "4. From your terminal:  \n",
    "   - cd into directory where you saved the .yml file (usualy same dir as this notebook)\n",
    "   - docker compose up -d\n",
    "   - verify (either in terminal or on Docker Desktop) the containers are running\n",
    "5. From your code (see notebook code below):\n",
    "   - Import milvus\n",
    "   - Connect to the local milvus server"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Pymilvus: 2.4.0\n",
      "\u001b[1A\u001b[1B\u001b[0G\u001b[?25l[+] Running 0/0\n",
      " \u001b[33m⠋\u001b[0m Network milvus               Created                                    \u001b[34m0.1s \u001b[0m\n",
      " \u001b[33m⠋\u001b[0m Container milvus-etcd        Created                                    \u001b[34m0.1s \u001b[0m\n",
      " \u001b[33m⠋\u001b[0m Container milvus-minio       Created                                    \u001b[34m0.1s \u001b[0m\n",
      " \u001b[33m⠋\u001b[0m Container milvus-standalone  Creating                                   \u001b[34m0.0s \u001b[0m\n",
      "\u001b[?25h\u001b[1A\u001b[1A\u001b[1A\u001b[1A\u001b[1A\u001b[0G\u001b[?25l[+] Running 0/4\n",
      " \u001b[33m⠙\u001b[0m Network milvus               Created                                    \u001b[34m0.2s \u001b[0m\n",
      " \u001b[33m⠙\u001b[0m Container milvus-etcd        Starting                                   \u001b[34m0.2s \u001b[0m\n",
      " \u001b[33m⠙\u001b[0m Container milvus-minio       Starting                                   \u001b[34m0.2s \u001b[0m\n",
      " \u001b[33m⠙\u001b[0m Container milvus-standalone  Created                                    \u001b[34m0.1s \u001b[0m\n",
      "\u001b[?25h\u001b[1A\u001b[1A\u001b[1A\u001b[1A\u001b[1A\u001b[0G\u001b[?25l[+] Running 0/4\n",
      " \u001b[33m⠹\u001b[0m Network milvus               Created                                    \u001b[34m0.3s \u001b[0m\n",
      " \u001b[33m⠹\u001b[0m Container milvus-etcd        Starting                                   \u001b[34m0.3s \u001b[0m\n",
      " \u001b[33m⠹\u001b[0m Container milvus-minio       Starting                                   \u001b[34m0.3s \u001b[0m\n",
      " \u001b[33m⠹\u001b[0m Container milvus-standalone  Created                                    \u001b[34m0.2s \u001b[0m\n",
      "\u001b[?25h\u001b[1A\u001b[1A\u001b[1A\u001b[1A\u001b[1A\u001b[0G\u001b[?25l[+] Running 2/4\n",
      " \u001b[33m⠸\u001b[0m Network milvus               Created                                    \u001b[34m0.4s \u001b[0m\n",
      " \u001b[32m✔\u001b[0m Container milvus-etcd        \u001b[32mStarted\u001b[0m                                    \u001b[34m0.3s \u001b[0m\n",
      " \u001b[32m✔\u001b[0m Container milvus-minio       \u001b[32mStarted\u001b[0m                                    \u001b[34m0.3s \u001b[0m\n",
      " \u001b[33m⠸\u001b[0m Container milvus-standalone  Starting                                   \u001b[34m0.3s \u001b[0m\n",
      "\u001b[?25h\u001b[1A\u001b[1A\u001b[1A\u001b[1A\u001b[1A\u001b[0G\u001b[?25l[+] Running 3/4\n",
      " \u001b[33m⠼\u001b[0m Network milvus               Created                                    \u001b[34m0.4s \u001b[0m\n",
      " \u001b[32m✔\u001b[0m Container milvus-etcd        \u001b[32mStarted\u001b[0m                                    \u001b[34m0.3s \u001b[0m\n",
      " \u001b[32m✔\u001b[0m Container milvus-minio       \u001b[32mStarted\u001b[0m                                    \u001b[34m0.3s \u001b[0m\n",
      " \u001b[32m✔\u001b[0m Container milvus-standalone  \u001b[32mStarted\u001b[0m                                    \u001b[34m0.4s \u001b[0m\n",
      "\u001b[?25hCONTAINER ID   IMAGE                                      COMMAND                  CREATED        STATUS                                     PORTS                                              NAMES\n",
      "600b515f14d5   milvusdb/milvus:v2.4.0-rc.1                \"milvus run standalo…\"   1 second ago   Up Less than a second (health: starting)   0.0.0.0:9091->9091/tcp, 0.0.0.0:19530->19530/tcp   milvus-standalone\n",
      "b2ef006a0846   quay.io/coreos/etcd:v3.5.5                 \"etcd -advertise-cli…\"   1 second ago   Up Less than a second (health: starting)   2379-2380/tcp                                      milvus-etcd\n",
      "55d385a6eb47   minio/minio:RELEASE.2023-03-20T20-16-18Z   \"/usr/bin/docker-ent…\"   1 second ago   Up Less than a second (health: starting)   0.0.0.0:9000-9001->9000-9001/tcp                   milvus-minio\n",
      "9091/tcp -> 0.0.0.0:9091\n",
      "19530/tcp -> 0.0.0.0:19530\n",
      "v2.4.0-rc.1-dev\n"
     ]
    }
   ],
   "source": [
    "# !pip install pymilvus\n",
    "import pymilvus, time\n",
    "from pymilvus import (connections, MilvusClient, utility)\n",
    "print(f\"Pymilvus: {pymilvus.__version__}\")\n",
    "\n",
    "####################################################################################################\n",
    "# Connect to local server running in Docker container.\n",
    "# Download the latest .yaml file: https://milvus.io/docs/install_standalone-docker.md\n",
    "# Or, download directly from milvus github (replace with desired version):\n",
    "# !wget https://github.com/milvus-io/milvus/releases/download/v2.4.0-rc.1/milvus-standalone-docker-compose.yml -O docker-compose.yml\n",
    "####################################################################################################\n",
    "# # Stop local milvus.\n",
    "# !docker compose down\n",
    "\n",
    "# Start Milvus standalone on docker, running quietly in the background.\n",
    "!docker compose up -d\n",
    "\n",
    "# Verify which local port the Milvus server is listening on\n",
    "!docker ps -a #19530/tcp\n",
    "\n",
    "# Add wait to avoid error message from trying to connect too soon.\n",
    "time.sleep(30)\n",
    "\n",
    "# Connect to the local server.\n",
    "connection = connections.connect(\n",
    "  alias=\"default\", \n",
    "  host='localhost', # or '0.0.0.0' or 'localhost'\n",
    "  port='19530'\n",
    ")\n",
    "\n",
    "# Get server version.\n",
    "print(utility.get_server_version())\n",
    "\n",
    "# Use no-schema Milvus client uses flexible json key:value format.\n",
    "mc = MilvusClient(connections=connection)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Error message if try to connect before docker up.**\n",
    "\n",
    "MilvusException                           Traceback (most recent call last)\n",
    "    145 except grpc.FutureTimeoutError as e:\n",
    "--> 146     raise MilvusException(\n",
    "    147         code=Status.CONNECT_FAILED,\n",
    "    148         message=f\"Fail connecting to server on {self._address}, illegal connection params or server unavailable\",\n",
    "    149     ) from e\n",
    "    150 except Exception as e:\n",
    "    151     raise e from e\n",
    "\n",
    "MilvusException: <MilvusException: (code=2, message=Fail connecting to server on localhost:19530, illegal connection params or server unavailable)>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Collection 'movies' exists in Milvus?\n",
      "Answer --> False!\n"
     ]
    }
   ],
   "source": [
    "# Check if a collection already exists.\n",
    "collection_name = \"movies\"\n",
    "has = utility.has_collection(collection_name)\n",
    "print(f\"Collection '{collection_name}' exists in Milvus?\")\n",
    "print(f\"Answer --> {has}!\")\n",
    "if has:\n",
    "    drop_result = utility.drop_collection(collection_name)\n",
    "    print(f\"Successfully dropped {collection_name}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[1A\u001b[1B\u001b[0G\u001b[?25l[+] Running 0/0\n",
      " \u001b[33m⠋\u001b[0m Container milvus-standalone  Stopping                                   \u001b[34m0.1s \u001b[0m\n",
      "\u001b[?25h\u001b[1A\u001b[1A\u001b[0G\u001b[?25l[+] Running 0/1\n",
      " \u001b[33m⠙\u001b[0m Container milvus-standalone  Stopping                                   \u001b[34m0.2s \u001b[0m\n",
      "\u001b[?25h\u001b[1A\u001b[1A\u001b[0G\u001b[?25l[+] Running 0/1\n",
      " \u001b[33m⠹\u001b[0m Container milvus-standalone  Stopping                                   \u001b[34m0.3s \u001b[0m\n",
      "\u001b[?25h\u001b[1A\u001b[1A\u001b[0G\u001b[?25l[+] Running 0/1\n",
      " \u001b[33m⠸\u001b[0m Container milvus-standalone  Stopping                                   \u001b[34m0.4s \u001b[0m\n",
      "\u001b[?25h\u001b[1A\u001b[1A\u001b[0G\u001b[?25l[+] Running 0/1\n",
      " \u001b[33m⠼\u001b[0m Container milvus-standalone  Stopping                                   \u001b[34m0.5s \u001b[0m\n",
      "\u001b[?25h\u001b[1A\u001b[1A\u001b[0G\u001b[?25l[+] Running 0/1\n",
      " \u001b[33m⠴\u001b[0m Container milvus-standalone  Stopping                                   \u001b[34m0.6s \u001b[0m\n",
      "\u001b[?25h\u001b[1A\u001b[1A\u001b[0G\u001b[?25l[+] Running 0/1\n",
      " \u001b[33m⠦\u001b[0m Container milvus-standalone  Stopping                                   \u001b[34m0.7s \u001b[0m\n",
      "\u001b[?25h\u001b[1A\u001b[1A\u001b[0G\u001b[?25l[+] Running 0/1\n",
      " \u001b[33m⠧\u001b[0m Container milvus-standalone  Stopping                                   \u001b[34m0.8s \u001b[0m\n",
      "\u001b[?25h\u001b[1A\u001b[1A\u001b[0G\u001b[?25l[+] Running 0/1\n",
      " \u001b[33m⠇\u001b[0m Container milvus-standalone  Stopping                                   \u001b[34m0.9s \u001b[0m\n",
      "\u001b[?25h\u001b[1A\u001b[1A\u001b[0G\u001b[?25l[+] Running 0/1\n",
      " \u001b[33m⠏\u001b[0m Container milvus-standalone  Stopping                                   \u001b[34m1.0s \u001b[0m\n",
      "\u001b[?25h\u001b[1A\u001b[1A\u001b[0G\u001b[?25l[+] Running 0/1\n",
      " \u001b[33m⠋\u001b[0m Container milvus-standalone  Stopping                                   \u001b[34m1.1s \u001b[0m\n",
      "\u001b[?25h\u001b[1A\u001b[1A\u001b[0G\u001b[?25l[+] Running 0/1\n",
      " \u001b[33m⠙\u001b[0m Container milvus-standalone  Stopping                                   \u001b[34m1.2s \u001b[0m\n",
      "\u001b[?25h\u001b[1A\u001b[1A\u001b[0G\u001b[?25l[+] Running 0/1\n",
      " \u001b[33m⠹\u001b[0m Container milvus-standalone  Stopping                                   \u001b[34m1.3s \u001b[0m\n",
      "\u001b[?25h\u001b[1A\u001b[1A\u001b[0G\u001b[?25l[+] Running 0/1\n",
      " \u001b[33m⠸\u001b[0m Container milvus-standalone  Stopping                                   \u001b[34m1.4s \u001b[0m\n",
      "\u001b[?25h\u001b[1A\u001b[1A\u001b[0G\u001b[?25l[+] Running 0/1\n",
      " \u001b[33m⠼\u001b[0m Container milvus-standalone  Stopping                                   \u001b[34m1.5s \u001b[0m\n",
      "\u001b[?25h\u001b[1A\u001b[1A\u001b[0G\u001b[?25l[+] Running 0/1\n",
      " \u001b[33m⠴\u001b[0m Container milvus-standalone  Stopping                                   \u001b[34m1.6s \u001b[0m\n",
      "\u001b[?25h\u001b[1A\u001b[1A\u001b[0G\u001b[?25l[+] Running 0/1\n",
      " \u001b[33m⠦\u001b[0m Container milvus-standalone  Stopping                                   \u001b[34m1.7s \u001b[0m\n",
      "\u001b[?25h\u001b[1A\u001b[1A\u001b[0G\u001b[?25l[+] Running 0/1\n",
      " \u001b[33m⠧\u001b[0m Container milvus-standalone  Stopping                                   \u001b[34m1.8s \u001b[0m\n",
      "\u001b[?25h\u001b[1A\u001b[1A\u001b[0G\u001b[?25l[+] Running 0/1\n",
      " \u001b[33m⠇\u001b[0m Container milvus-standalone  Stopping                                   \u001b[34m1.9s \u001b[0m\n",
      "\u001b[?25h\u001b[1A\u001b[1A\u001b[0G\u001b[?25l[+] Running 0/1\n",
      " \u001b[33m⠏\u001b[0m Container milvus-standalone  Stopping                                   \u001b[34m2.0s \u001b[0m\n",
      "\u001b[?25h\u001b[1A\u001b[1A\u001b[0G\u001b[?25l[+] Running 0/1\n",
      " \u001b[33m⠋\u001b[0m Container milvus-standalone  Stopping                                   \u001b[34m2.1s \u001b[0m\n",
      "\u001b[?25h\u001b[1A\u001b[1A\u001b[0G\u001b[?25l[+] Running 0/1\n",
      " \u001b[33m⠙\u001b[0m Container milvus-standalone  Stopping                                   \u001b[34m2.2s \u001b[0m\n",
      "\u001b[?25h\u001b[1A\u001b[1A\u001b[0G\u001b[?25l\u001b[34m[+] Running 1/1\u001b[0m\n",
      " \u001b[32m✔\u001b[0m Container milvus-standalone  \u001b[32mRemoved\u001b[0m                                    \u001b[34m2.2s \u001b[0m\n",
      " \u001b[33m⠋\u001b[0m Container milvus-etcd        Stopping                                   \u001b[34m0.1s \u001b[0m\n",
      " \u001b[33m⠋\u001b[0m Container milvus-minio       Stopping                                   \u001b[34m0.1s \u001b[0m\n",
      "\u001b[?25h\u001b[1A\u001b[1A\u001b[1A\u001b[1A\u001b[0G\u001b[?25l[+] Running 2/3\n",
      " \u001b[32m✔\u001b[0m Container milvus-standalone  \u001b[32mRemoved\u001b[0m                                    \u001b[34m2.2s \u001b[0m\n",
      " \u001b[32m✔\u001b[0m Container milvus-etcd        \u001b[32mRemoved\u001b[0m                                    \u001b[34m0.1s \u001b[0m\n",
      " \u001b[33m⠙\u001b[0m Container milvus-minio       Stopping                                   \u001b[34m0.2s \u001b[0m\n",
      "\u001b[?25h\u001b[1A\u001b[1A\u001b[1A\u001b[1A\u001b[0G\u001b[?25l[+] Running 2/3\n",
      " \u001b[32m✔\u001b[0m Container milvus-standalone  \u001b[32mRemoved\u001b[0m                                    \u001b[34m2.2s \u001b[0m\n",
      " \u001b[32m✔\u001b[0m Container milvus-etcd        \u001b[32mRemoved\u001b[0m                                    \u001b[34m0.1s \u001b[0m\n",
      " \u001b[33m⠹\u001b[0m Container milvus-minio       Stopping                                   \u001b[34m0.3s \u001b[0m\n",
      "\u001b[?25h\u001b[1A\u001b[1A\u001b[1A\u001b[1A\u001b[0G\u001b[?25l[+] Running 2/3\n",
      " \u001b[32m✔\u001b[0m Container milvus-standalone  \u001b[32mRemoved\u001b[0m                                    \u001b[34m2.2s \u001b[0m\n",
      " \u001b[32m✔\u001b[0m Container milvus-etcd        \u001b[32mRemoved\u001b[0m                                    \u001b[34m0.1s \u001b[0m\n",
      " \u001b[33m⠸\u001b[0m Container milvus-minio       Stopping                                   \u001b[34m0.4s \u001b[0m\n",
      "\u001b[?25h\u001b[1A\u001b[1A\u001b[1A\u001b[1A\u001b[0G\u001b[?25l[+] Running 2/3\n",
      " \u001b[32m✔\u001b[0m Container milvus-standalone  \u001b[32mRemoved\u001b[0m                                    \u001b[34m2.2s \u001b[0m\n",
      " \u001b[32m✔\u001b[0m Container milvus-etcd        \u001b[32mRemoved\u001b[0m                                    \u001b[34m0.1s \u001b[0m\n",
      " \u001b[33m⠼\u001b[0m Container milvus-minio       Stopping                                   \u001b[34m0.5s \u001b[0m\n",
      "\u001b[?25h\u001b[1A\u001b[1A\u001b[1A\u001b[1A\u001b[0G\u001b[?25l[+] Running 2/3\n",
      " \u001b[32m✔\u001b[0m Container milvus-standalone  \u001b[32mRemoved\u001b[0m                                    \u001b[34m2.2s \u001b[0m\n",
      " \u001b[32m✔\u001b[0m Container milvus-etcd        \u001b[32mRemoved\u001b[0m                                    \u001b[34m0.1s \u001b[0m\n",
      " \u001b[33m⠴\u001b[0m Container milvus-minio       Stopping                                   \u001b[34m0.6s \u001b[0m\n",
      "\u001b[?25h\u001b[1A\u001b[1A\u001b[1A\u001b[1A\u001b[0G\u001b[?25l[+] Running 4/3\n",
      " \u001b[32m✔\u001b[0m Container milvus-standalone  \u001b[32mRemoved\u001b[0m                                    \u001b[34m2.2s \u001b[0m\n",
      " \u001b[32m✔\u001b[0m Container milvus-etcd        \u001b[32mRemoved\u001b[0m                                    \u001b[34m0.1s \u001b[0m\n",
      " \u001b[32m✔\u001b[0m Container milvus-minio       \u001b[32mRemoved\u001b[0m                                    \u001b[34m0.6s \u001b[0m\n",
      " \u001b[32m✔\u001b[0m Network milvus               \u001b[32mRemoved\u001b[0m                                    \u001b[34m0.0s \u001b[0m\n",
      "\u001b[?25h"
     ]
    }
   ],
   "source": [
    "# Stop local milvus.\n",
    "!docker compose down"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2. Zilliz free tier  <a class=\"anchor\" id=\"zilliz_free\"></a>\n",
    "\n",
    "This section uses [Zilliz](https://zilliz.com), free tier.  If you have not already, sign up for a [free trial](https://cloud.zilliz.com/signup).  \n",
    "\n",
    "If you already have a Zilliz account and want to use free tier, just be sure to select \"Starter\" option when you [create your cluster](https://docs.zilliz.com/docs/create-cluster).  ❤️‍🔥 **In other words, everybody gets free tier!!**  \n",
    "- One free tier cluster per account.\n",
    "- Per free tier cluster, up to two collections at a time. (Think of a collection like a database table. Each collection has an index, schema, and consistency-level).\n",
    "- Each free tier collection can support up to 1M vectors (Think of this like rows in a database table).\n",
    "\n",
    "If you require additional clusters, we recommend subscribing to either our Serverless or Enterprise plan (Zilliz-managed AWS, Google, or Azure).\n",
    "\n",
    "### 👩 Set up instructions for Zilliz \n",
    "\n",
    "1. From [cloud.zilliz.com](cloud.zilliz.com), click **\"+ Create Cluster\"**\n",
    "2. Select <i>**Starter**</i> option for the cluster and click **\"Next: Create Collection\"**\n",
    "   <div>\n",
    "   <img src=\"../images/zilliz_cluster_choose.png\" width=\"60%\"/>\n",
    "   </div>\n",
    "\n",
    "1. Name your collection with a <i>**Collection Name**</i> and click **\"Create Collection and Cluster\"**.\n",
    "2. From the Clusters page, \n",
    "   - copy the cluster uri and save somewhere locally.\n",
    "   - copy your cluster API KEY.  Keep this private! \n",
    "     <div>\n",
    "     <img src=\"../images/zilliz_cluster_uri_token.png\" width=\"80%\"/>\n",
    "     </div>\n",
    "\n",
    "3. Add the API KEY to your environment variables.  See this [article for instructions](https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety) how in either Windows or Mac/Linux environment.\n",
    "4. In Jupyter, you'll also need .env file (in same dir as notebooks) containing lines like this:\n",
    "   - ZILLIZ_API_KEY=value\n",
    "5. In your code, connect to your Zilliz cluster, see code example below."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Type of server: Zilliz Cloud Vector Database(Compatible with Milvus 2.3)\n"
     ]
    }
   ],
   "source": [
    "import os\n",
    "from pymilvus import (connections, MilvusClient, utility)\n",
    "TOKEN = os.getenv(\"ZILLIZ_API_KEY\")\n",
    "\n",
    "# Connect to Zilliz cloud using endpoint URI and API key TOKEN.\n",
    "# TODO change this.\n",
    "CLUSTER_ENDPOINT=\"https://in03-xxxx.api.gcp-us-west1.zillizcloud.com:443\"\n",
    "CLUSTER_ENDPOINT=\"https://in03-48a5b11fae525c9.api.gcp-us-west1.zillizcloud.com:443\"\n",
    "connections.connect(\n",
    "  alias='default',\n",
    "  #  Public endpoint obtained from Zilliz Cloud\n",
    "  uri=CLUSTER_ENDPOINT,\n",
    "  # API key or a colon-separated cluster username and password\n",
    "  token=TOKEN,\n",
    ")\n",
    "\n",
    "# Check if the server is ready and get colleciton name.\n",
    "print(f\"Type of server: {utility.get_server_version()}\")\n",
    "\n",
    "# Use no-schema Milvus client uses flexible json key:value format.\n",
    "# https://milvus.io/docs/using_milvusclient.md\n",
    "mc = MilvusClient(\n",
    "    uri=CLUSTER_ENDPOINT,\n",
    "    # API key or a colon-separated cluster username and password\n",
    "    token=TOKEN)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "py310",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.8"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
